package com.ylr.storage.config;

import com.ylr.storage.framework.properties.MinioProperties;
import io.minio.MinioClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2023-09-08 15:16:04
 * className: YlrStorageConfig
 * version: 1.0
 * description:
 */
@Configuration
public class YlrStorageConfig {

    @Resource(type = MinioProperties.class)
    private MinioProperties minioProperties;

    /**
     * 注入MinIO操作Bean
     */
    @Bean
    public MinioClient minioClient() {
        MinioClient minioClient = MinioClient.builder()
                .endpoint(minioProperties.getEndpoint())
                .credentials(minioProperties.getAccessKey(), minioProperties.getSecretKey())
                .build();
        return minioClient;
    }
}
